/*
 * include/40/omp.h.var
 * $Revision: 41674 $
 * $Date: 2012-06-05 08:33:35 -0500 (Tue, 05 Jun 2012) $
 */

/* <copyright>
    Copyright (c) 1985-2013 Intel Corporation.  All Rights Reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

      * Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
      * Neither the name of Intel Corporation nor the names of its
        contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

</copyright> */


#ifdef _MSC_VER
#pragma once
#endif

#ifndef __OMP_H
#   define __OMP_H

#include "xomp_exp.h"

#ifndef KMP_VERSION_MAJOR
#define KMP_VERSION_MAJOR XOMP_VERSION_MAJOR
#endif
#ifndef KMP_VERSION_MINOR
#define KMP_VERSION_MINOR XOMP_VERSION_MINOR
#endif
#ifndef KMP_VERSION_BUILD
#define KMP_VERSION_BUILD XOMP_VERSION_BUILD
#endif
#ifndef KMP_BUILD_DATE
#define KMP_BUILD_DATE XOMP_BUILD_DATE
#endif

#   include <stdlib.h>

#ifdef __cplusplus
EXTERN_C_BEGIN
#endif

/*
#   if defined(_WIN32)
#       define __KAI_KMPC_CONVENTION __cdecl
#   else
#       define __KAI_KMPC_CONVENTION
#   endif
*/

    /* schedule kind constants */
    typedef enum omp_sched_t {
	omp_sched_static  = 1,
	omp_sched_dynamic = 2,
	omp_sched_guided  = 3,
	omp_sched_auto    = 4
    } omp_sched_t;

    /* set API functions */
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_num_threads (int);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_dynamic     (int);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_nested      (int);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_max_active_levels (int);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_schedule          (omp_sched_t, int);

    /* query API functions */
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_num_threads  (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_dynamic      (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_nested       (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_max_threads  (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_thread_num   (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_num_procs    (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_in_parallel      (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_active_level        (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_level               (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_ancestor_thread_num (int);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_team_size           (int);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_thread_limit        (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_get_max_active_levels   (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_get_schedule            (omp_sched_t *, int *);

    /* lock API functions */
    typedef struct omp_lock_t {
        void * _lk;
    } omp_lock_t;

    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_init_lock    (omp_lock_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_lock     (omp_lock_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_unset_lock   (omp_lock_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_destroy_lock (omp_lock_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_test_lock    (omp_lock_t *);

    /* nested lock API functions */
    typedef struct omp_nest_lock_t {
        void * _lk;
    } omp_nest_lock_t;

    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_init_nest_lock    (omp_nest_lock_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_set_nest_lock     (omp_nest_lock_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_unset_nest_lock   (omp_nest_lock_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  omp_destroy_nest_lock (omp_nest_lock_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  omp_test_nest_lock    (omp_nest_lock_t *);

    /* time API functions */
    XOMP_GLOBALAPI double XOMP_CALLCONV  omp_get_wtime (void);
    XOMP_GLOBALAPI double XOMP_CALLCONV  omp_get_wtick (void);

    /* OpenMP 4.0 */
    XOMP_GLOBALAPI int  XOMP_CALLCONV  omp_get_default_device (void);
    XOMP_GLOBALAPI void XOMP_CALLCONV  omp_set_default_device (int);
    XOMP_GLOBALAPI int  XOMP_CALLCONV  omp_get_num_devices (void);
    XOMP_GLOBALAPI int  XOMP_CALLCONV  omp_get_num_teams (void);
    XOMP_GLOBALAPI int  XOMP_CALLCONV  omp_get_team_num (void);
    XOMP_GLOBALAPI int  XOMP_CALLCONV  omp_get_cancellation (void);


    /* kmp API functions */
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_get_stacksize          (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_stacksize          (int);
    XOMP_GLOBALAPI size_t XOMP_CALLCONV  kmp_get_stacksize_s        (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_stacksize_s        (size_t);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_get_blocktime          (void);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_get_library            (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_blocktime          (int);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_library            (int);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_library_serial     (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_library_turnaround (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_library_throughput (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_defaults           (const char *);

    /* Intel affinity API */
    typedef void * kmp_affinity_mask_t;

    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_set_affinity             (kmp_affinity_mask_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_get_affinity             (kmp_affinity_mask_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_get_affinity_max_proc    (void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_create_affinity_mask     (kmp_affinity_mask_t *);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_destroy_affinity_mask    (kmp_affinity_mask_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_set_affinity_mask_proc   (int, kmp_affinity_mask_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_unset_affinity_mask_proc (int, kmp_affinity_mask_t *);
    XOMP_GLOBALAPI int    XOMP_CALLCONV  kmp_get_affinity_mask_proc   (int, kmp_affinity_mask_t *);

    /* OpenMP 4.0 affinity API */
	typedef enum omp_proc_bind_t {
		proc_bind_false = 0,
		proc_bind_true,
		proc_bind_master,
		proc_bind_close,
		proc_bind_spread,
		proc_bind_disabled,
		proc_bind_intel,    // use KMP_AFFINITY interface
		proc_bind_default
	} omp_proc_bind_t;

    XOMP_GLOBALAPI omp_proc_bind_t XOMP_CALLCONV omp_get_proc_bind (void);

    XOMP_GLOBALAPI void * XOMP_CALLCONV  kmp_malloc  (size_t);
    XOMP_GLOBALAPI void * XOMP_CALLCONV  kmp_calloc  (size_t, size_t);
    XOMP_GLOBALAPI void * XOMP_CALLCONV  kmp_realloc (void *, size_t);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_free    (void *);

    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_warnings_on(void);
    XOMP_GLOBALAPI void   XOMP_CALLCONV  kmp_set_warnings_off(void);

/*#   undef __KAI_KMPC_CONVENTION*/

    /* Warning:
       The following typedefs are not standard, deprecated and will be removed in a future release.
    */
    typedef int     omp_int_t;
    typedef double  omp_wtime_t;

#ifdef __cplusplus
EXTERN_C_END
#endif

#endif /* __OMP_H */

